<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input type="text" placeholder="enter the name you search" v-model="keyword"/>
      <button @click="clickSearch">Search</button>
    </div>
  </section>
</template>

<script>
export default {
  name: 'SearchHeader',
  data () {
    return {
      keyword: ''
    }
  },
  methods: {
    clickSearch () {
      // 有值才搜索
      if (this.keyword) {
        // dispatch触发搜索的action调用
        this.$store.dispatch('userSearch/search', this.keyword)

        // 清除输入
        this.keyword = ''
      }
      
    }
  }
};
</script>

<style scoped></style>
